import { Module } from 'vuex';
import { RootState } from '../index';

export interface MenuItem {
  path: string;
  name: string;
  icon?: string;
  children?: MenuItem[];
}

export interface MainState { 
  menus: MenuItem[];
}

const mainModule: Module<MainState, RootState> = {
  namespaced: true,
  state: {
    menus: [],
  },
  mutations: {
    SET_MENUS(state, menus: MenuItem[]) {
      state.menus = menus;
    },
  },
  actions: {
    async loadMenus({ commit }) {
      try {
        // 这里可以调用后端 API 获取菜单
        // const response = await api.getMenus();
        // commit('SET_MENUS', response.data);
        
        // 临时使用写死的菜单数据
        const staticMenus: MenuItem[] = [
          {
            path: '/assistant/chat',
            name: '智能对话',
            icon: 'ChatDotRound',
          },
          {
            path: '/assistant/document',
            name: '公文写作',
            icon: 'Edit',
          },
          {
            path: '/assistant/tasks',
            name: '任务管理',
            icon: 'List',
          },
          {
            path: '/assistant/settings',
            name: '设置',
            icon: 'Setting',
          },
        ];
        
        commit('SET_MENUS', staticMenus);
      } catch (error) {
        console.error('加载菜单失败:', error);
      }
    },
  },
  getters: {
    menus: (state) => state.menus,
  },
};

export default mainModule; 